// SPDX-License-Identifier: Apache-2.0
// Copyright Authors of Cilium

// Code generated by lister-gen. DO NOT EDIT.

package v2alpha1

import (
	v2alpha1 "github.com/cilium/cilium/pkg/k8s/apis/cilium.io/v2alpha1"
	"k8s.io/apimachinery/pkg/api/errors"
	"k8s.io/apimachinery/pkg/labels"
	"k8s.io/client-go/tools/cache"
)

// CiliumNodeConfigLister helps list CiliumNodeConfigs.
// All objects returned here must be treated as read-only.
type CiliumNodeConfigLister interface {
	// List lists all CiliumNodeConfigs in the indexer.
	// Objects returned here must be treated as read-only.
	List(selector labels.Selector) (ret []*v2alpha1.CiliumNodeConfig, err error)
	// CiliumNodeConfigs returns an object that can list and get CiliumNodeConfigs.
	CiliumNodeConfigs(namespace string) CiliumNodeConfigNamespaceLister
	CiliumNodeConfigListerExpansion
}

// ciliumNodeConfigLister implements the CiliumNodeConfigLister interface.
type ciliumNodeConfigLister struct {
	indexer cache.Indexer
}

// NewCiliumNodeConfigLister returns a new CiliumNodeConfigLister.
func NewCiliumNodeConfigLister(indexer cache.Indexer) CiliumNodeConfigLister {
	return &ciliumNodeConfigLister{indexer: indexer}
}

// List lists all CiliumNodeConfigs in the indexer.
func (s *ciliumNodeConfigLister) List(selector labels.Selector) (ret []*v2alpha1.CiliumNodeConfig, err error) {
	err = cache.ListAll(s.indexer, selector, func(m interface{}) {
		ret = append(ret, m.(*v2alpha1.CiliumNodeConfig))
	})
	return ret, err
}

// CiliumNodeConfigs returns an object that can list and get CiliumNodeConfigs.
func (s *ciliumNodeConfigLister) CiliumNodeConfigs(namespace string) CiliumNodeConfigNamespaceLister {
	return ciliumNodeConfigNamespaceLister{indexer: s.indexer, namespace: namespace}
}

// CiliumNodeConfigNamespaceLister helps list and get CiliumNodeConfigs.
// All objects returned here must be treated as read-only.
type CiliumNodeConfigNamespaceLister interface {
	// List lists all CiliumNodeConfigs in the indexer for a given namespace.
	// Objects returned here must be treated as read-only.
	List(selector labels.Selector) (ret []*v2alpha1.CiliumNodeConfig, err error)
	// Get retrieves the CiliumNodeConfig from the indexer for a given namespace and name.
	// Objects returned here must be treated as read-only.
	Get(name string) (*v2alpha1.CiliumNodeConfig, error)
	CiliumNodeConfigNamespaceListerExpansion
}

// ciliumNodeConfigNamespaceLister implements the CiliumNodeConfigNamespaceLister
// interface.
type ciliumNodeConfigNamespaceLister struct {
	indexer   cache.Indexer
	namespace string
}

// List lists all CiliumNodeConfigs in the indexer for a given namespace.
func (s ciliumNodeConfigNamespaceLister) List(selector labels.Selector) (ret []*v2alpha1.CiliumNodeConfig, err error) {
	err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) {
		ret = append(ret, m.(*v2alpha1.CiliumNodeConfig))
	})
	return ret, err
}

// Get retrieves the CiliumNodeConfig from the indexer for a given namespace and name.
func (s ciliumNodeConfigNamespaceLister) Get(name string) (*v2alpha1.CiliumNodeConfig, error) {
	obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name)
	if err != nil {
		return nil, err
	}
	if !exists {
		return nil, errors.NewNotFound(v2alpha1.Resource("ciliumnodeconfig"), name)
	}
	return obj.(*v2alpha1.CiliumNodeConfig), nil
}
